﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DiscoveryLogic.Common.Utilities;

namespace DiscoveryLogic.Analytics.DataObjects.Filters
{
    public class EntityQuery
    {
        public EntityType EntityType;
        public string FieldName;
        public SqlOp Op;
        public string Against;
    }

    public enum SqlOp
    {
        Equals,Greater,Less,NotEqual,In,Like
    }

    public class SqlOpHelper
    {
        public static string ToString(SqlOp op)
        {
            switch(op)
            {
                case SqlOp.Equals:
                    return "=";
                case SqlOp.Greater:
                    return ">";
                case SqlOp.Less:
                    return "<";
                case SqlOp.NotEqual:
                    return "<>";
                case SqlOp.In:
                    return "in";
                case SqlOp.Like:
                    return "like";
                default:
                    return "";
            }
        }

        public static SqlOp Parse(string op)
        {
            if(op=="=")
                return SqlOp.Equals;
            else if(op==">")
                return SqlOp.Greater;
            else if(op=="<")
                return SqlOp.Less;
            else if(op=="<>")
                return SqlOp.NotEqual;
            else if(op=="in")
                return SqlOp.In;
            else
                return SqlOp.Like;
        }
    }
}
